package com.cocolove2.library_cocodialog.dialogs;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;

import com.cocolove2.library_cocodialog.CornerUtils;
import com.cocolove2.library_cocodialog.dialogs.base.CocoAlertDialogBase;

/**
 * Dialog like Material Design Dialog
 */
public class MaterialCocoDialog extends CocoAlertDialogBase<MaterialCocoDialog> {

    public MaterialCocoDialog(Context context) {
        super(context);

        /** default value*/
        mTitleTextColor = Color.parseColor("#DE000000");
        mTitleTextSize = 22f;
        mMessageTextColor = Color.parseColor("#8a000000");
        mMessageTextSize = 16f;
        mBtnNegativeTextColor = Color.parseColor("#383838");
        mBtnPositiveTextColor = Color.parseColor("#468ED0");
        mBtnNeutralTextColor = Color.parseColor("#00796B");
        /** default value*/
    }

    @Override
    protected View onCreateView(Context context, ViewGroup parent) {
        /** title */
        mLlContainer.addView(mTvTitle);
        /** content */
        mLlContainer.addView(mTvMessage);
        /**btns*/
        mLlBtns.setGravity(Gravity.END);
        mLlBtns.addView(mTvBtnNegative);
        mLlBtns.addView(mTvBtnNeutral);
        mLlBtns.addView(mTvBtnPositive);

        mTvBtnPositive.setPadding(dp2px(DEFAULT_CONTENT_PADDING), dp2px(DEFAULT_CONTENT_PADDING / 2), dp2px(DEFAULT_CONTENT_PADDING), dp2px(DEFAULT_CONTENT_PADDING / 2));
        mTvBtnNeutral.setPadding(dp2px(DEFAULT_CONTENT_PADDING), dp2px(DEFAULT_CONTENT_PADDING / 2), dp2px(DEFAULT_CONTENT_PADDING), dp2px(DEFAULT_CONTENT_PADDING / 2));
        mTvBtnNegative.setPadding(dp2px(DEFAULT_CONTENT_PADDING), dp2px(DEFAULT_CONTENT_PADDING / 2), dp2px(DEFAULT_CONTENT_PADDING), dp2px(DEFAULT_CONTENT_PADDING / 2));

        mLlBtns.setPadding(dp2px(DEFAULT_CONTENT_PADDING / 2), dp2px(DEFAULT_CONTENT_PADDING / 2), dp2px(DEFAULT_CONTENT_PADDING / 2), dp2px(DEFAULT_CONTENT_PADDING / 2));

        mLlContainer.addView(mLlBtns);

        return mLlContainer;
    }

    @Override
    protected void setupUiView() {
        super.setupUiView();
        /**set background color and corner radius */
        mLlContainer.setBackground(CornerUtils.cornerDrawable(mDialogBgColor, mCornerRadius));

        mTvBtnNegative.setVisibility(mBtnNegativeText == null ? View.GONE : View.VISIBLE);
        mTvBtnPositive.setVisibility(mBtnPositiveText == null ? View.GONE : View.VISIBLE);
        mTvBtnNeutral.setVisibility(mBtnNeutralText == null ? View.GONE : View.VISIBLE);

        mTvBtnNegative.setBackground(CornerUtils.btnSelector(mCornerRadius, mDialogBgColor, mBtnPressColor, -2));
        mTvBtnPositive.setBackground(CornerUtils.btnSelector(mCornerRadius, mDialogBgColor, mBtnPressColor, -2));
        mTvBtnNeutral.setBackground(CornerUtils.btnSelector(mCornerRadius, mDialogBgColor, mBtnPressColor, -2));
    }


}
